ANIMA.add("anima.database.jslocal", function(A) {
	
A.namespace("anima.database.jslocal");

A.anima.database.jslocal = {

   defaultDbDir: "db/",
   defaultUidDir: "uid/",
   defaultJSName: "component.js",
         
   resolver: function(webid) {
      var dirFile = {
             directory : ANIMA.anima.base + this.defaultDbDir,
             file : this.defaultJSName
      };
      
      if (webid[0] === "<")
         webid = webid.substr(1, webid.length-2);
       
      var protocol = webid.indexOf(":");
      if (protocol >= 0) {
         protocol++;
         while (webid[protocol] === "/")
            protocol++;
         webid = webid.substr(protocol);
      }
   
      var posP = webid.lastIndexOf("/");
      if (posP >= 0) {
         var lastDot = webid.lastIndexOf(".");
         var part1 = webid.substring(0, posP);
         var part2 = webid.substring(posP+1, lastDot+1);
         part1 = part1.replace(/[\.\/]/g, "_");
         part2 = part2.replace(/\./g, "/");
         dirFile.directory += part1 + "/" + part2;
         dirFile.file = webid.substring(lastDot+1) + ".js";
      } else
         dirFile.directory += this.defaultUidDir + webid + "/";
      
      return dirFile;
   },
   
   resolverDirectory: function(webid) {
      var dirFile = this.resolver(webid);
      
      return dirFile.directory;
   },
   
   resolverFile: function(webid) {
      var dirFile = this.resolver(webid);
      
      return dirFile.directory + dirFile.file;
   },
   
   buildComponentConfig: function(webid, superWebid) {
      var componentModules = {};
      
      // alert("webid: " + webid + "; superWebid: " + superWebid);
      
      if (superWebid && superWebid != null && superWebid != "") {
         componentModules[superWebid] = {
            requires: ["anima.component", "anima.component.base"],
            fullpath: A.anima.database.jslocal.resolverFile(superWebid)
         };
         componentModules[webid] = {
            requires: [superWebid],
            fullpath: A.anima.database.jslocal.resolverFile(webid)
         };
      } else {
         componentModules[webid] = {
            requires: ["anima.component", "anima.component.base"],
            fullpath: A.anima.database.jslocal.resolverFile(webid)
         };
      }
      
      var componentConfig = {
         modules:  componentModules
      };
      
      return componentConfig;
   }
	
};

});